package com.moorror.codegenvel.common.table;

import com.intellij.ui.HighlightableCellRenderer;
import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;

import javax.swing.*;
import java.awt.*;

/**
 * @Author jiyanghuang
 * @Date 2025/9/21 13:26
 * 这么写只为能显示Tree节点，采用覆盖的方式
 */
public class MRHighlightableCellRenderer extends HighlightableCellRenderer {

    @Override
    public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
        Component re = super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
        if(value instanceof DefaultMutableTreeTableNode){
            DefaultMutableTreeTableNode treeTableNode = (DefaultMutableTreeTableNode)value;
            Object userObject = treeTableNode.getUserObject();
            if(userObject instanceof TreeLineWrap){
                TreeLineWrap treeLineWrap = (TreeLineWrap)userObject;
                ColumnDesc columnDesc = treeLineWrap.columnTree();
                setText(columnDesc.getValueShow());
                return re;
            }
        }
        setText("helloWorld");
        return re;
    }
}
